$(function () {
    // sm2公钥
    const pubkeyHex = "3059301306072a8648ce3d020106082a811ccf5501822d034200041149b874ec2a110a9d583d86c904df2d8c15bab061288751c1ad267f7c63e73ca563ec6e194ae771d3a16cf70f424ffc1759eaf0a547ea4c1090bde6c7744286";
    // 取消表单的默认事件
    $('#login').submit(function(){return false;})
    $('#login').click(function (){
        let username = $('#username').val();
        let password = $('#password').val();
        //对请求报文加密
        //username = sm2Encrypt(username, pubkeyHex, 1);
        //password = sm2Encrypt(password, pubkeyHex, 0);
        $.ajax({
            // 请求方式
            type: 'post'
            // 预期服务器返回的数据类型
            ,dataType: 'json'
            // 请求地址
            ,url: '/jszhao-eform/user/doLogin'
            ,data: {'username': username, 'password': password}
            ,success: function (res) {
                debugger
                if (res.code == '200') {
                    debugger
                    window.location.href = '/jszhao-eform/index.html';
                } else {
                    alert(res.msg);
                }
            }
            ,error: function (err) {
                debugger;
                console.log('err', err);
            }
        });
    });
});